﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DNA.OpenAPI.Opml;

namespace DNA.Mvc.Services
{
    public abstract class OpmlOutlineGeneratorBase:Command
    {
        protected abstract IEnumerable<OpmlOutline> OnCreateOutlines();
        
        public override void Execute(CommandContext context)
        {
            var outlines = OnCreateOutlines();
            if ((outlines != null) && (outlines.Count() > 0))
                ((OpmlDocument)context.Bag).Body.Outlines.AddRange(outlines);
        }
    }
}
